<template>
  <a-modal
    title="粘贴内容"
    :visible="visible"
    :width="640"
    okText="粘贴"
    cancelText="取消"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <a-form layout="vertical" :model="form" :rules="rules">
      <a-form-item label="粘贴内容" field="pasteData">
        <a-textarea v-model="form.pasteData" :rows="4" placeholder="请输入要粘贴的内容" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>

<script>
export default {
  name: 'PasteContext',
  data () {
    return {
      visible: false,
      form: {
        pasteData: ''
      },
      rules: {
        pasteData: [
          { required: true, message: '请输入要粘贴的内容', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    open () {
      this.form.pasteData = ''
      this.visible = true
    },
    handleCancel () {
      this.$emit('close')
      this.visible = false
    },
    handleOk () {
      this.$emit('ok', this.form.pasteData)
      this.visible = false
    }
  }
}
</script>
